import { EntityHelper } from '../../utils/entity-helper';
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
import { AdminUser } from '../../admin-users/entities/admin-user.entity';

@Entity('menu')
export class Menu extends EntityHelper {
	@PrimaryGeneratedColumn()
	id: number;

	@Column()
	path: string;

	@Column({ name: 'parent_id' })
	parentId: number;

	@Column()
	icon: string;

	@Column()
	title: string;

	@Column({ name: 'sort_number' })
	sortNumber: number;

	@Column({ name: 'is_directory', default: 1 })
	isDirectory: number;

	@Column({ name: 'user_id' })
	userId: string;

	@CreateDateColumn({ name: 'create_time' })
	createTime!: Date;

	@UpdateDateColumn({ name: 'update_time' })
	updateTime!: Date;

	@ManyToOne((type) => AdminUser, (userAdmin) => userAdmin.userId)
	@JoinColumn({ name: 'user_id' })
	userAdmin: AdminUser;
}
